+2005-09-27 Øyvind Kolås <pippin@gimp.org>
+
+ * babl/babl-util.h,
+ * babl/babl-util.c: (babl_rel_avg_error): moved buffer comparison
+ function to one place.
+ * babl/babl-classes.h: Added error field to fishes, made path length
+ dynamic.
+ * babl/babl-internal.h: added misc global constants.
+ * babl/babl-internal.c: created caching accessors in classes, to avoid
+ very large bootstrapping time.
+ * babl/babl-conversion.c: (test_create), (babl_conversion_cost),
+ (babl_conversion_error):
+ * babl/babl-format.c: (test_create), (babl_format_loss):
+ * babl/babl-type.c: (babl_type_is_symmetric):
+
+2005-09-27 Øyvind Kolås <pippin@gimp.org>
+
+ Moved html generator stats code into a seperate source fil in core,
+ babl now creates /tmp/babl-stats.txt when the BABL_STATS enviroment
+ variable is set.
+
+ * babl/Makefile.am:
+ * babl/babl.c:
+ * tests/babl_fish_path_dhtml.c: (main):
+ * babl/babl-fish-stats.c: (table_destination_each).
+
2005-09-19 Øyvind Kolås <pippin@gimp.org>
* docs/index-static.html.in: s/DHTML/interactive/
BablInstance instance;
union Babl *source;
union Babl *destination;
- int processings;
- long pixels;
+ int processings;
+ long pixels;
+ double error;
} BablFish;
BablFish fish;
double cost;
double loss;
- BablConversion *conversion[BABL_MAX_PATH_LENGTH];
+ BablConversion *conversion[BABL_HARD_MAX_PATH_LENGTH];
int conversions;
} BablFishPath;
);
}
-#define pixels 256
+#define test_pixels 256
static double *
test_create (void)
srandom (20050728);
- test = babl_malloc (sizeof (double) * pixels * 4);
+ test = babl_malloc (sizeof (double) * test_pixels * 4);
- for (i = 0; i < pixels * 4; i++)
+ for (i = 0; i < test_pixels * 4; i++)
test [i] = (double) random () / RAND_MAX;
return test;
fish_from = babl_fish_reference (fmt, ref_fmt);
test = test_create ();
- original = babl_calloc (pixels, fmt->format.bytes_per_pixel);
- clipped = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel);
- destination = babl_calloc (pixels, fmt->format.bytes_per_pixel);
- transformed = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel);
+ original = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
+ clipped = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel);
+ destination = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
+ transformed = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel);
- babl_process (fish_to, test, original, pixels);
- babl_process (fish_from, original, clipped, pixels);
- babl_process (fish_to, clipped, destination, pixels);
- babl_process (fish_from, destination, transformed, pixels);
+ babl_process (fish_to, test, original, test_pixels);
+ babl_process (fish_from, original, clipped, test_pixels);
+ babl_process (fish_to, clipped, destination, test_pixels);
+ babl_process (fish_from, destination, transformed, test_pixels);
- {
- int i;
-
- for (i=0;i<pixels*4;i++)
- {
- loss += fabs (clipped[i] - test[i]);
- }
- loss /= pixels;
-
- }
+ loss = babl_rel_avg_error (clipped, test, test_pixels*4);
+ fish_to->fish.processings-=2;
+ fish_from->fish.processings-=2;
+ fish_to->fish.pixels-=test_pixels*2;
+ fish_from->fish.pixels -= test_pixels*2;
+
babl_free (original);
babl_free (clipped);
babl_free (destination);
* Boston, MA 02111-1307, USA.
*/
+#include <stdlib.h>
#include "babl-internal.h"
static const char *class_names[] =
babl_assert (BABL_IS_BABL (babl));
return babl->instance.name;
}
-
-static int
-each_conversion (Babl *babl,
- void *user_data)
-{
- babl_conversion_error (&babl->conversion);
- return 0;
-}
-
-static int
-each_format (Babl *babl,
- void *user_data)
-{
- babl_format_loss (babl);
- return 0;
-}
-
-static int
-gen_type_format_for_model (Babl *type, void *userdata)
-{
- babl_format_with_model_as_type (userdata, type);
- return 0;
-}
-
-static int
-gen_formats_for_model (Babl *model, void *userdata)
-{
- babl_type_each (gen_type_format_for_model, model);
- return 0;
-}
-
-void
-babl_extension_post_load (void)
-{
- babl_conversion_each (each_conversion, NULL);
- babl_format_each (each_format, NULL);
- return;
- babl_model_each (gen_formats_for_model, NULL);
- babl_format_each (each_format, NULL);
-}
-
#error babl-internal.h included after babl.h
#endif
-#define BABL_MAX_COMPONENTS 32
-#define BABL_MAX_PATH_LENGTH 5
+#define BABL_MAX_COMPONENTS 32
+#define BABL_HARD_MAX_PATH_LENGTH 8
#include <stdlib.h>
#include <stdio.h>
Babl * babl_conversion_find (void *source,
void *destination);
double babl_conversion_error (BablConversion *conversion);
+long babl_conversion_cost (BablConversion *conversion);
long babl_conversion_process (Babl *conversion,
void *source,
void *destination,
long n);
Babl * babl_extension_base (void);
-void babl_extension_post_load (void);
Babl * babl_extender (void);
void babl_set_extender (Babl *new_extender);
Babl * babl_fish_reference (Babl *source,
Babl *destination);
Babl * babl_fish_simple (BablConversion *conversion);
+void babl_fish_stats (FILE *file);
Babl * babl_fish_path (Babl *source,
Babl *destination);
babl_process (fish_to, clipped, destination, samples);
babl_process (fish_from, destination, transformed, samples);
+ fish_from->fish.processings-=2;
+ fish_to->fish.processings-=2;
+ fish_from->fish.pixels -= samples*2;
+ fish_to->fish.pixels -= samples*2;
+
{
int cnt=0;
int i;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <math.h>
#include "babl-memory.h"
#include "babl-internal.h"
gettimeofday (&measure_time, NULL);
return msecs(measure_time) - msecs(start_time);
}
+
+double
+babl_rel_avg_error (double *imgA,
+ double *imgB,
+ long samples)
+{
+ double error = 0.0;
+ int i;
+
+ for (i=0; i<samples; i++)
+ error += fabs (imgA[i] - imgB[i]);
+
+ if (error >= 0.000001)
+ error /= samples;
+ else
+ error = 0.0;
+
+ return error;
+}
+
#ifndef _BABL_UTIL_H
#define _BABL_UTIL_H
+#include <math.h>
+
void babl_add_ptr_to_list (void ***list,
void *new);
void *user_data);
unsigned int babl_ticks (void);
+
+double
+babl_rel_avg_error (double *imgA,
+ double *imgB,
+ long samples);
#endif